package com.tianpengtech.admin.fairbankno;
import java.util.Map;

import org.apache.commons.lang.StringUtils;

import com.jfinal.plugin.activerecord.Model;
import com.tianpengtech.common.exception.ValidateException;
import com.tianpengtech.admin.AbstractAdmin;
import com.tianpengtech.common.model.fairauth.FairAuth;
import com.tianpengtech.common.model.fairbankno.FairBankNo;
import com.tianpengtech.common.search.EqualCondition;
import com.tianpengtech.common.search.LikeCondition;
import com.tianpengtech.common.search.QueryConstructor;

public class FairBankNoAdminServiceImpl extends AbstractAdmin{

	@Override
	public void beforeAdd(Model<?> model) throws ValidateException {

	}

	@Override
	public void beforeQueryById(Model<?> model, int id) {

	}

	@Override
	public void beforeUpdate(Model<?> model) throws ValidateException {

	}

	@Override
	public void beforeDelete(Model<?> model) {

	}

	@Override
	public void builderSQLExpected(Model< ? > model,
			QueryConstructor queryConstruct, Map< String, Object > params) {

		queryConstruct.and(new EqualCondition(FairBankNo.DELETETAG, FairBankNo.DEL_NO));
		String realName = model.getStr(FairBankNo.REAL_NAME);
		if(StringUtils.isNotBlank(realName)){
			queryConstruct.and(new LikeCondition(FairBankNo.REAL_NAME, "%"+realName+"%"));
		}
	}

	@Override
	public String tableName() {
		return FairBankNo.dao.tableName();
	}

}